import { createStore } from 'vuex';

export default createStore({
  state: {
    todos: [] as string[],
    dones: [] as string[],
    deletes: [] as string[]
  },
  getters: {},
  mutations: {
    add(state, value) {
      state.todos.push(value);
    },
    delete(state, index) {
      // 获取当前待办列表索引对应的值
      const item = state.todos[index];
      // 从当前待办列中删除对应索引的值
      state.todos.splice(index, 1);
      // 把记录的删除的值存放到已删除列表中
      state.deletes.push(item);
    },
    done(state, index) {
      // 获取当前待办列表索引对应的值
      const item = state.todos[index];
      // 从当前待办列中删除对应索引的值
      state.todos.splice(index, 1);
      // 把记录的删除的值存放到已完成列表中
      state.dones.push(item);
    }
  },
  actions: {},
  modules: {}
});
